#pragma once
#include "Define.h"
#include <iostream>
#include <vector>

namespace Next
{
	using namespace std;
	using namespace Defines;

	namespace Patterns
	{
		class CObservable;

		class CObserver
		{
		public:
			virtual void UpdateLogLine(CObservable* obj, vector<stLine*> arg) = 0;
			virtual void Update(CObservable* obj, unsigned int arg) = 0;

			CObserver(void){};
			~CObserver(void){};
		};

		class CObservable 
		{
		private:
			vector<CObserver*> vecObservers;
			string _tag;

		public:
			void Notify(vector<stLine*> arg)
			{
				vector<CObserver*>::iterator it = vecObservers.begin();

				while(it != vecObservers.end())
				{
					CObserver* observer = *it;
					observer->UpdateLogLine(this, arg);
					it++;
				}
			}

			void Notify(unsigned int arg)
			{
				vector<CObserver*>::iterator it = vecObservers.begin();

				while(it != vecObservers.end())
				{
					CObserver* observer = *it;
					observer->Update(this, arg);
					it++;
				}
			}

			void AddObserver(CObserver* observer)
			{
				this->vecObservers.push_back(observer);
			}

			string Tag()
			{
				return _tag;
			}

		public:
			CObservable(string tag)
			{
				_tag = tag;
			}

			~CObservable(void){}
		};
	}
}


